package com.twu.biblioteca;

/**
 * Created by sharan on 9/6/14.
 */
public class Book {

    private String name;
    private String author;
    private int yearOfPublication;
    private boolean issued;

    public Book(String name, String author, int yearOfPublication) {

        this.name = name;
        this.author = author;
        this.yearOfPublication = yearOfPublication;
        this.issued = false;
    }

    public String getName() {

        return this.name;
    }

    public String getAuthor() {

        return this.author;
    }

    public int getYearOfPublication() {

        return this.yearOfPublication;
    }

    public void setIssued() {

        this.issued = true;
    }

    public void setNotIssued() {

        this.issued = false;
    }

    public boolean getIssueStatus() {

        return this.issued;
    }

    @Override
    public boolean equals(Object book){

        if(book instanceof Book){

            if(this.getAuthor().equals(((Book) book).getAuthor())){
                if(this.getName().equals(((Book)book).getName())){
                    if(this.getYearOfPublication() == ((Book)book).getYearOfPublication()){
                        return true;
                    }
                }
            }
        }
        return false;
    }

    @Override
    public String toString(){

        return this.getName() + this.getAuthor() + this.getYearOfPublication();
    }
}
